package com.joven.product.api.business.client.feign;

import com.joven.infra.common.model.PageResult;
import com.joven.infra.common.model.Response;
import com.joven.product.service.client.dto.*;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import javax.validation.Valid;

/**
 * 商品客户端
 *
 * @author Joven
 * @date 2022-01-06 18:21:27
 */
@FeignClient(url = "http://127.0.0.1:8081", contextId = "remoteProductService", value = "product-service", path = "/product")
public interface ProductService {

    @ApiOperation("分页查询")
    @PostMapping("/getByPage")
    Response<PageResult<ProductDTO>> getByPage(@RequestBody ProductPageQueryDTO pageQuery);

    @ApiOperation("根据id查询详情")
    @GetMapping("/getDetailById")
    Response<ProductDetailDTO> getDetailById(@RequestParam("id") Long id);

    @ApiOperation("创建")
    @PostMapping("/create")
    Response<Boolean> create(@RequestBody @Validated ProductCreateDTO createDTO);


    @ApiOperation("编辑")
    @PostMapping("/edit")
    Response<Boolean> edit(@RequestBody @Valid ProductEditDTO editDTO);
}
